﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Threading.Tasks;

namespace EnglishStudy.View
{
    public partial class SmallTile : UserControl
    {
        public SmallTile()
        {
            InitializeComponent();
            LayoutRoot.DataContext = this;
            Start();
        }

         public async void Start()
            {
             Random rnd = new Random();
             while (true)
             {
                 int delay = rnd.Next(3000, 12000); // creates a number between 1 and 12
                 await Task.Delay(delay);
                 this.livetile.Begin();

                 delay = rnd.Next(3000, 12000); // creates a number between 1 and 12
                 await Task.Delay(delay);
                 this.livetile1.Begin();
             }
                
            }

        public static readonly DependencyProperty BindingTextValueProperty = DependencyProperty.Register(
                                          "Percentage",
                                          typeof(string),
                                          typeof(SmallTile),
                                          new PropertyMetadata(""));
        public string Title 
        {
            get
            {
                return (GetValue(BindingTextValueProperty) as string);
            }
            set
            {
                SetValue(BindingTextValueProperty, value);
            }
        }

        public static readonly DependencyProperty BindingTitleValueProperty = DependencyProperty.Register(
                                  "Title",
                                  typeof(string),
                                  typeof(SmallTile),
                                  new PropertyMetadata(""));
        public string Percentage
        {
            get
            {
                return GetValue(BindingTitleValueProperty) as string;
            }
            set
            {
                SetValue(BindingTitleValueProperty, value);
            }
        }

        public static readonly DependencyProperty IconSourceProperty = DependencyProperty.Register(
                                  "IconSource",
                                  typeof(ImageSource),
                                  typeof(SmallTile),
                                  null);
        public ImageSource IconSource
        {
            get
            {
                return GetValue(IconSourceProperty) as ImageSource;
            }
            set
            {
                SetValue(IconSourceProperty, value);
            }
        }
    }
}
